<script>
  import { useStore } from '@/stores/user.js'
  import {commonStore} from "@/stores/common.js"
  import {systemStore} from "@/stores/system.js"
  import {getInfo} from '@/api/login'
	export default {
		onLaunch: function() {
      const UserStore = useStore()
      const CommonStore = commonStore()
      const SystemStore = systemStore()
      // /**缓存读取数据**/
      UserStore.setCacheData()
      /*****每次打开小程序的时候更新用户的数据******/
      const {userInfo} = UserStore
      if(userInfo.token){
        getInfo().then(res=>{
          UserStore.setUserInfo({
            ...res.user
          })
        })
      }



      /*****获取导航高度*****/
      uni.getSystemInfo({
        success: function(res) {
          SystemStore.setStatusBarInfo({
            statusBarHeight:uni.getSystemInfoSync().statusBarHeight,
            windowHeight:res.windowHeight
          })

        }
      });
      /*****获取-----------------------定位******/
      // 引入腾讯地图SDK
      var QQMapWX = require('./static/qqmap-wx-jssdk.min.js');
      var qqmapsdk;
      // 实例化API核心类
      qqmapsdk = new QQMapWX({
        key: 'LKJBZ-ILRL6-5GTSI-E443R-NEXIE-6QF2R'
      });
      uni.getLocation({
        type: "gcj02",
        altitude: true,
        geocode: true,
        success: function(res) {
          // 逆地址解析
          qqmapsdk.reverseGeocoder({
            location:{
              latitude: res.latitude,
              longitude: res.longitude
            },
            success: function (result) {
              CommonStore.setCityInfo({
                latitude: res.latitude,
                longitude: res.longitude,
                cityCode: result.result.ad_info.city_code.replace('156',''),
                cityName:result.result.ad_info.city
              })
              CommonStore.setLocationAuthorization(true)
              console.log(CommonStore.cityInfo)

            },
            fail: function (error) {
              console.log('error',error);
            }
          })
        },
        fail(err) {
          //位置授权失败之后
          CommonStore.setLocationAuthorization(false)
          console.log(err,'fail')
        }
      });
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
  @import url("@/static/scss/animate.min.css");
  @import '@/static/scss/index.scss';
  @import "@/uni_modules/uview-plus/index.scss";
  @for $i from 1 to 150 {
    .fs#{$i} {
      font-size: #{$i}rpx
    }
    .width-#{$i} {
      width: #{$i}rpx;
    }
    .height-#{$i} {
      height: #{$i}rpx;
    }
    .mg#{$i} {
      margin: #{$i}rpx
    }

    .mgt-#{$i} {
      margin-top: #{$i}rpx;
    }

    .mgb-#{$i} {
      margin-bottom: #{$i}rpx;
    }

    .mgl-#{$i} {
      margin-left: #{$i}rpx
    }

    .mgr-#{$i} {
      margin-right: #{$i}rpx;
    }

    .pd-#{$i} {
      padding: #{$i}rpx;
    }

    .pdt-#{$i} {
      padding-top: #{$i}rpx;
    }

    .pdb-#{$i} {
      padding-bottom: #{$i}rpx;
    }

    .pdl-#{$i} {
      padding-left: #{$i}rpx;
    }

    .pdr-#{$i} {
      padding-right: #{$i}rpx;
    }

    .pdlr-#{$i} {
      padding-left: #{$i}rpx;
      padding-right: #{$i}rpx;
    }

    .br-#{$i} {
      border-radius: #{$i}rpx;
    }
    .imgWH-#{$i} {
      width: #{$i}rpx;
      height: #{$i}rpx
    }
  }


.df {
  display: flex;
}

.flex1 {
  flex: 1;
}

.flex-ac {
  align-items: center;
}

.flex-jc {
  justify-content: center;
}

.flex-col {
  flex-direction: column;

}

.flex-jc-sb {
  justify-content: space-between;
}

.justify-between {
  justify-content: space-between;
}

.flex-jc-end {
  justify-content: flex-end;

}

.flex-jc-ac {
  justify-content: center;
  align-items: center;
}

.flex-jc-sa {
  justify-content: space-around;
}

.flex-warp {
  flex-wrap: wrap;
}
.align-center{
  align-items: center;
}
.flex-end {
  align-items: flex-end;
  justify-content: flex-end;
}

.w100 {
  width: 100%;
}

.h100 {
  height: 100%;
}

.pos-re {
  position: relative;
}

.box-s {
  box-sizing: border-box;
}

.border_b_1 {
  border-bottom: 1px solid #e5e5e5;
}

.border_r_1 {
  border-right: 1rpx solid #E5E5E5;
}

</style>
